
clear all
set mem 5g 
set matsize 11000
set more off
cap log close 

gl raw_path = "/Users/Wei/Dropbox/Census"

cd "/Users/Wei/Dropbox/Twins/Restat-Twins/Data"

log using "Twins-Document.log",replace 

use "$raw_path/1982dta", clear
la var hhoftyp "Type of household (Collective/Family)"
la var province "Province Code"
la var prefec "Prefecture Code"
la var county "County Code"
la var commune "Community Code"
la var hhcode "Household Code"
la var persnnb "Total number of people"
la var brhnb81 "Number of Births in 1981"
la var brhnb81 "Number of Deaths in 1981"
la var persnnbA "Residence living outside"
la var id "Individual ID"
la var namecode "Name in code"
la var releahh "Relationship to household head"
la var sex "Sex (1 for Male; 2 for Female)"
la var age "Age in years"
la var nationty "Ethnicity"
la var registat "Type of residence registration"
la var edulevel "Education Level (1 College Graduate; 2, College; 3, Senior High; 4, Junior High; 5. Primary; 6, Illiterate)"
la var industry "Industry"
la var occupation "Occupation"
la var noworkpn "Status if not working"
la var maristat "Marital Status (1, Unmarried; 2, Married; 3,Widowed; 4, Divorced)"
la var chldborn "Number of Children born" 
la var chldlive "Number of Children alive"
la var bthord81 "Fertility Status in 1981 (0, No birth; 1, first birth; 2, Second Birth; 3, third birth; 4, Fourth birth; 5. Fifth birth)"
la var houseid "House ID"
la var housesize "House Size" 
la var rural "Rural"
la var file "File number"
la var nid "Individual ID" 
la var nhouseid "House ID"

* Variables used in this study 
keep hhoftyp sex age releahh prov sex edulevel rural nationty chldborn chldlive
de
su 
corr hhoftyp sex age releahh sex edulevel rural nationty chldborn chldlive // prov string here

use "$raw_path/census90", clear
la var prov "Province code"
la var prefect "Prefecture code"
la var county "County code"
la var address "Community code"
la var house "Household code"
la var name "Name ID"
la var relation "Relationship to household head"
la var sex "Sex"
la var age "Birth year & Month"
la var nation "Ethnicity"
la var regstat "Type of residence registration"
la var houstype "Type of household"
la var usuresid "Residence (Province) in 1985"
la var usuresty "Residence (Urban/Town/Rural) in 1985"
la var migrate "Reason to come"
la var edulevel "Education level"
la var edustat "Status of Education"
la var industry "Industry code"
la var occu "Occupation code"
la var nworksta "Status if not working"
la var maristat "Marital Status" 
la var numbirm "Number of Children born (Male)" 
la var numbirf "Number of Children born (Female)"
la var numbirm "Number of Children Survive (Male)"
la var numsurf "Number of Children Survive (Female)"
la var birth "Birth status in 1989"
la var houssize "Household Size" 
de 
* Variables used in this study 
keep nation prov prefect county address house houstype usuresty usuresid age relation edulevel numbir* numsur* sex
de
su 
corr nation-edulevel sex

use "$raw_path/census2000", clear
la var id "Household ID"
la var h02 "Type of household (Family/Collective)"
la var h031 "Number of Men living here"
la var h032 "Number of Women living here"
la var h041 "Number Men staying over half year here"
la var h042 "Number Women staying over half year here"
la var h051 "Number Men going out half year here"
la var h052 "Number Women going out half year here"
la var h061 "Number of men temporarily living here"
la var h062 "Number of women temporarily living here"
la var h071 "Number Boys Born 1999.11.1 - 2000.10.31"
la var h072 "Number Girls Born 1999.11.1 - 2000.10.31"
la var h081 "Number Deaths of Men"
la var h082 "Number Deaths of Women"
la var h09 "Number of rooms"
la var h10 "Size of house (sq meters)"
la var h11 "Usage of house (Living = 1; Other Production = 2)"
la var h12 "With other household (Yes = 1; No = 2)"
la var h13 "Year of Building"
la var h14 "Type of Building (1 = Flat, 2 = below 6 floors, 3 = 7 and over)"
la var h15 "Material of Wall"
la var h16 "Kitchen condition"
la var h17 "Fuel used for cooking"
la var h18 "Use Running Water?"
la var h19 "Have Hot water?"
la var h20 "Toilet condition"
la var h21 "Source of house"
la var h22 "How much spent on purchase or build (categories)"
la var h23 "Rent categories"
la var r01 "Household Head"
la var r02 "Relation to Head"
la var r03 "Sex"
la var r041 "Year of Birth"
la var r042 "Month of Birth"
la var r05 "Ethnicity"
la var r061 "Register of Hukou - type"
la var r062 "Register of Hukou - Where"
la var r063 "Register of Hukou - Specific province"
la var r07 "Type of Hukou"
la var r081 "Birth place (Category)"
la var r082 "Birth Province"
la var r09 "Education level"
la var r101 "Where are you from? - Categorical answer"
la var r102 "Province"
la var r103 "Prefecture"
la var r104 "County"
la var r11 "Type of Place you are from"
la var r12 "Reason to move"
la var r131 "Residence 5 years ago"
la var r132 "Specific Province"
la var r14 "Literate?"
la var r151 "Education level"
la var r152 "Adult Education?"
la var r16 "Education condition"
la var r17 "Work or not"
la var r18 "Days to work"
la var r19 "Industry"
la var r20 "Occupatoin"
la var r211 "Why not work?"
la var r212 "Others: Specify"
la var r22 "Income Main Source"
la var r23 "Marital Status"
la var r241 "Year of First Marriage"
la var r242 "Month of First Marriage"

la var r251 "Number of boys born alive"
la var r252 "Number of girls born alive"
la var r253 "Number of boys survive"
la var r254 "Number of girls survive"

la var r261 "Fertility Situation IN 1999.11.1.-2000.10.31"
la var r262 "Month of fertility"
la var r263 "Gender of baby"
la var r264 "Month of fertility of Second Baby in 12 months"
la var r265 "Gender of Baby"
la var ra0 "Type of Residence"
* More details can be found in pdf file named "2000 Census" (Chinese)

ren h02 hubie 
ren r07 hktype 
ren r041 birth_year 
ren r042 birth_month 
ren r02 relation 
drop h0 hubie 
ren r03 sex 
ren r23 marr
ren r241 marryy1st
ren r242 marrym1st
ren r251 numbirm
ren r252 numbirf
ren r253 numsurm
ren r254 numsurf
ren r151 schooling
ren r05 nation
ren ra0 resid_type

* Variables used in this study 
keep  hktype birth_year birth_month sex relation marr marryy1st marrym1st numbir* numsur* schooling nation resid_type
de
su 
corr hktype-marr



use "$raw_path/pdata1_num_ren", clear // Labels are shown properly in Chinese 
la var 	region	"Region"
la var 	hhid	"Household ID"
la var 	hhtype	"Type of Household"
la var 	n_hh	"Number of People living in"
la var 	n_hk_hh	"Number of people with local hukou"
la var 	n_mbirth_hh	"Number of boys born"
la var 	n_fbirth_hh	"Number of girls born"
la var 	n_mdeath_hh	"Number of men deaths"
la var 	n_fdeath_hh	"Number of women deaths"
la var 	use_h	"Use for house"
la var 	nf_build	"Number of floors"
la var 	m_build	"Structure of building"
la var 	t_build	"Year of building built up"
la var 	nroom_h	"Number of rooms"
la var 	nsm_h	"Area of house"
la var 	ifshare_h	"Shared with others"
la var 	ifwat_h	"if running water"
la var 	ifkit_h	"if kitchen"
la var 	fuel_h	"Fuel for cook"
la var 	iftoil_h	"if Toilet"
la var 	ifbath_h	"if Bath"
la var 	how_h	"Source of living room"
la var 	c1wan_h	"How much spent on house (10 thousand)"
la var 	c2qian_h	"How much spent on house (thousand)"
la var 	rent_h	"Rent per month"
la var 	name	"Name ID"
la var 	relation	"Relation to Head"
la var 	sex	"Sex"
la var 	year_birth	"Year of Birth"
la var 	moth_birth	"Month of Birth"
la var 	ethnic	"Ethnicity"
la var 	where_hk	"Where is the Hukou"
la var 	county_hk	"Hukou County"
la var 	city_hk	"Hukou City"
la var 	prov_hk	"Hukou Province"
la var 	where_res	"Where is the residence in 2000"
la var 	county_res	"County"
la var 	city_res	"City"
la var 	prov_res	"Province"
la var 	time_out	"Time of leaving hukou place"
la var 	cause_out	"Reason to leave"
la var 	hkptype	"Type of hukou place"
la var 	hktype	"Type of hukou"
la var 	nbroth	"Number of brothers"
la var 	nsister	"Number of sisters"
la var 	health	"Health status"
la var 	where_1y_res	"Residence in last year"
la var 	prov_1y_res	"Province in last year"
la var 	where_5y_res	"Residence in last 5 years"
la var 	prov_5y_res	"Province in last 5 years"
la var 	literacy	"Literate or not"
la var 	educ	"Education level"
la var 	ifend_educ	"Education status"
la var 	ifwork	"Work status"
la var 	hour_w	"Hours on work"
la var 	ind	"Industry"
la var 	occ	"Occupation"
la var 	type_unit	"Type of work last week"
la var 	status_w	"Status of working"
la var 	ifcont	"Labor contract situation"
la var 	term_cont	"Fixed term contract period"
la var 	income	"Income"
la var 	cause_nw	"Cause of no income"
la var 	how_sjob	"Seek for job in 3 months"
la var 	ifready_job	"Work eligibility"
la var 	dur_nw	"Time of not working"
la var 	insu_unem	"Unemployment Insurance"
la var 	pension	"Pension"
la var 	medicare	"Medical Care Unsurance"
la var 	source_liv	"Main income"
la var 	maritus	"Marital status"
la var 	year_mar1	"Year of first marriage"
la var 	month_mar1	"month of first marriage"
la var 	n_mbirth	"Number of boys born alive"
la var 	n_fbirth	"Number of girls born alive"
la var 	n_mchild	"Number of boys survive"
la var 	n_fchild	"Number of girls survive"
la var 	ifbirth	"Fertility Situation"
la var 	month_b1	"Month of fertility"
la var 	sex_b1	"Gender of Baby"
la var 	month_b2	"Month of fertility 2nd one"
la var 	sex_b2	"Gender of Baby"
la var 	age	"Age"
la var 	ave_age	"Average age"
la var 	power_2	"Power"
la var 	city_flag	"Type of residence"
la var 	reg_flag	"Region"
* more details can be found in the xls file named 

keep region hhid hhtype hktype sex ethnic year_birth moth_birth relation maritus year_mar1 month_mar1 educ age n_*birth n_*child city_flag
de
su
corr region-maritus

log close 





